<?
require_once 'config.php';
$url = $_SERVER['REQUEST_URI'];
if(preg_match('/\?page=/',$url)){
   $current_page =(int) preg_replace('/^.+page=/','',$url);
}
if(!is_int($current_page)) $current_page = 1;
if(gettype($current_page) != "integer") $current_page = 1;
if($current_page <0 || !$current_page) $current_page = 1;
$templateBlog = new TemplateBlog();
$templateBlog->page_size = 8;
$templateBlog->page = $current_page;
$blog = $templateBlog->blog();
$total = $templateBlog->blog_total();
?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="vi" lang="vi" xmlns:og="http://ogp.me/ns#" xmlns:fb="">
<head>
   <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
   <link type="image/x-icon" href="/favicon.ico" rel="icon" />
   
   <title>Blog</title>
   <meta name="description" content=""/>
   <meta name="keywords" content=""/>
   <meta name="AUTHOR" content="Sudo.vn" />
   <meta name="COPYRIGHT" content="Sudo.vn" />
   <meta name="ROBOTS" content="INDEX, FOLLOW" />
   <meta name="RATING" content="GENERAL" />
   <!-- css -->   
   <link rel="stylesheet" type="text/css" href="<?=TEMPLATE_PATH?>css/jquery-ui.css" media='all'/>
   <link rel="stylesheet" type="text/css" href="<?=TEMPLATE_PATH?>css/home.css" media='all'/>
   <link rel="stylesheet" type="text/css" href="<?=TEMPLATE_PATH?>css/service.css" media='all'/>
   <link rel="stylesheet" type="text/css" href="<?=TEMPLATE_PATH?>css/blog.css" media='all'/>
   
   <!-- js -->
   <script type="text/javascript" src="<?=TEMPLATE_PATH?>js/jquery-1.9.0.min.js"></script>
   <script type="text/javascript" src="<?=TEMPLATE_PATH?>js/common.js"></script>
</head>
<body> 
   <div class="global_container">
      <? include('view/common/vic_header.php')?>
      <div class="content_wrap">
         <div class="cumbs_wrap">
            <div class="crumbs width">
               <ul>              
            		<li><a href="/">Trang chủ </a> &nbsp;>&nbsp; </li>
                   
            		<li><a href="/blog.html">Blog </a></li>
                  
            	</ul>
               <div class="clear"></div>
            </div>
         </div>
         <div class="content_inner width">
            <div class="content_left">
               <? include('view/common/vic_post_new.php')?>     
               <div class="clear"></div>          
            </div>
            <div class="content_right">
               <div class="services_wrap">   
                  
                  <?
                     if($blog){
                     foreach($blog as $row){
                  ?>
                     <div class="blog_one">
                        
                        
                        <div class="image_date">
                           <div class="image_day"><?=date('d',$row['blo_date'])?></div>
                           <div class="image_mounth"><?=date('F',$row['blo_date'])?></div>
                           <div class="post-view"> <?=$row['blo_views']?> Views</div>
                        </div>
                        <div class="blog_info">
                           <a href="<?=generate_blog_detail_url($row)?>"><p class="blog_title"><?=$row['blo_title']?> </p></a>
                           <div class="blog_line"></div>
                           <div class="image_blog">
                              <img src="<?=blog_img.'medium_'.$row['blo_picture']?>"/>
                           </div>
                           
                           <div class="blog_description"><?=cut_string($row['blo_summary'],200)?></div>
                           <div class="readmore"> 
                              <a href="<?=generate_blog_detail_url($row)?>">
                                 Đọc thêm</a> 
                           </div>
                        </div>
                     </div>
                  <?
                     }}else echo "Chưa có bài viết!"
                  ?>
                  <div class="services_pagebreak">
                     <?=generatePageBar('',$current_page,$templateBlog->page_size,$total,'','main_page_btn','page_selected','<<','>>','Đầu','Cuối',1,1)?>
                  </div>
               </div>
            </div>
         </div>
         <div class="clear"></div>
      </div>
      <div class="clear"></div>
      <?include('view/common/vic_footer.php')?>
   </div>
</body>
</html>
<script>
$(document).ready(function(){
   $(window).scroll(function(){
      var y = $(window).scrollTop();    
      
      var elementOffset = $('.post_new').offset().top;
      if(y <= 233){
         $('.post_new').removeClass('post_new_fixed')         
      }
      if(y > elementOffset){
         $('.post_new').addClass('post_new_fixed');         
      } ;
      if(y>500) $('.post_new').css({'top':'32px'});
      else{ $('.post_new').css({'top':'-20px'})}
   });
})
</script>